jQuery(document).ready(function($) {


	UE.getEditor('editor').ready(function(){ 
		setContent(sessionStorage.title,sessionStorage.main,sessionStorage.tag);
//		setContent("biaotiyo","jahaha","hahah,hahahja");
		$("#send").click(function(){

			// 检查文章内容是否为空
			var has = hasContent();
			if(has){
				var title = $("#articleTitle").val();
				// 检查文章标题是否为空
				if(title==" "){alert("文章标题不允许为空！");}
				else{
					var articleContent = getContent();//文章内容
					var articleOutline = getContentTxt();//文章概要
					var articleTag = $("#articleTip").val();//文章标签
					var articleAuthor = sessionStorage.userName;//文章作者
					var createTime = new Date();//发表时间

					
					if(sessionStorage.id==" " || sessionStorage.id==undefined){
						$.post(publishURL, {
							html : articleContent,
							outline : articleOutline,
							tag : articleTag,
							userID : sessionStorage.userId,
							createTime : createTime,
							title:title
							}, 
							function(data) {
								if(data.message=="success"){
									sessionStorage.id = " ";
									sessionStorage.title = " ";
									sessionStorage.tag = " ";
									sessionStorage.main = " ";
									setContent(" "," "," ");	
								}
								alert(data.message);
						});
					}
					else{
						$.post(updateURL, {
							articleId : sessionStorage.id, //文章id
							html : articleContent,
							outline : articleOutline,
							tag : articleTag,
							userID : sessionStorage.userId,
							createTime : createTime,
							title:title
							}, 
							function(data) {
								if(data.message=="success"){
									sessionStorage.id = " ";
									sessionStorage.title = " ";
									sessionStorage.tag = " ";
									sessionStorage.main = " ";
									setContent(" "," "," ");	
								}
								alert(data.message);
						});
					}
					


					

				}
			}
		});
	});
	
});